Produced by Araxis Merge on 2020-08-14 00:01:33 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto v3.2.3/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Plugin/Model/Layer/Filter | Item.php | 2018-10-10 20:33:20 +0000 |
| 2 | Porto v3.2.4/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Plugin/Model/Layer/Filter | Item.php | 2020-06-26 11:11:14 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 15 | 256 |
| Changed | 11 | 25 |
| Inserted | 3 | 3 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | <?php | 1 | <?php | |||
| 2 | /** | 2 | /** | |||
| 3 | * Mageplaza | 3 | * Mageplaza | |||
| 4 | * | 4 | * | |||
| 5 | * NOTICE OF LICENSE | 5 | * NOTICE OF LICENSE | |||
| 6 | * | 6 | * | |||
| 7 | * This source file is subject to the Mageplaza.com license that is | 7 | * This source file is subject to the Mageplaza.com license that is | |||
| 8 | * available through the world-wide-web at this URL: | 8 | * available through the world-wide-web at this URL: | |||
| 9 | * https://www.mageplaza.com/LICENSE.txt | 9 | * https://www.mageplaza.com/LICENSE.txt | |||
| 10 | * | 10 | * | |||
| 11 | * DISCLAIMER | 11 | * DISCLAIMER | |||
| 12 | * | 12 | * | |||
| 13 | * Do not edit or add to this file if you wish to upgrade this extension to newer | 13 | * Do not edit or add to this file if you wish to upgrade this extension to newer | |||
| 14 | * version in the future. | 14 | * version in the future. | |||
| 15 | * | 15 | * | |||
| 16 | * @category Mageplaza | 16 | * @category Mageplaza | |||
| 17 | * @package Mageplaza_LayeredNavigation | 17 | * @package Mageplaza_LayeredNavigation | |||
| 18 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | 18 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | |||
| 19 | * @license https://www.mageplaza.com/LICENSE.txt | 19 | * @license https://www.mageplaza.com/LICENSE.txt | |||
| 20 | */ | 20 | */ | |||
| 21 | 21 | |||||
| 22 | namespace Mageplaza\LayeredNavigation\Plugin\Model\Layer\Filter; | 22 | namespace Mageplaza\LayeredNavigation\Plugin\Model\Layer\Filter; | |||
| 23 | 23 | |||||
| 24 | use Magento\Framework\App\RequestInterface; | 24 | use Magento\Framework\App\RequestInterface; | |||
| 25 | use Magento\Framework\Exception\LocalizedException; | |||||
| 25 | use Magento\Framework\UrlInterface; | 26 | use Magento\Framework\UrlInterface; | |||
| 26 | use Magento\Theme\Block\Html\Pager; | 27 | use Magento\Theme\Block\Html\Pager; | |||
| 27 | use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; | 28 | use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; | |||
| 28 | 29 | |||||
| 29 | /** | 30 | /** | |||
| 30 | * Class Item | 31 | * Class Item | |||
| 31 | * @package Mageplaza\LayeredNavigation\Model\Plugin\Layer\Filter | 32 | * @package Mageplaza\LayeredNavigation\Model\Plugin\Layer\Filter | |||
| 32 | */ | 33 | */ | |||
| 33 | class Item | 34 | class Item | |||
| 34 | { | 35 | { | |||
| 35 | /** @var UrlInterface */ | 36 | /** @var UrlInterface */ | |||
| 36 | protected $_url; | 37 | protected $_url; | |||
| 37 | 38 | |||||
| 38 | /** @var Pager */ | 39 | /** @var Pager */ | |||
| 39 | protected $_htmlPagerBlock; | 40 | protected $_htmlPagerBlock; | |||
| 40 | 41 | |||||
| 41 | /** @var RequestInterface */ | 42 | /** @var RequestInterface */ | |||
| 42 | protected $_request; | 43 | protected $_request; | |||
| 43 | 44 | |||||
| 44 | /** @var \Mageplaza\LayeredNavigation\Helper\Data */ | 45 | /** @var LayerHelper */ | |||
| 45 | protected $_moduleHelper; | 46 | protected $_moduleHelper; | |||
| 46 | 47 | |||||
| 47 | /** | 48 | /** | |||
| 48 | * Item constructor. | 49 | * Item constructor. | |||
| 49 | * | 50 | * | |||
| 50 | * @param UrlInterface $url | 51 | * @param UrlInterface $url | |||
| 51 | * @param Pager $htmlPagerBlock | 52 | * @param Pager $htmlPagerBlock | |||
| 52 | * @param RequestInterface $request | 53 | * @param RequestInterface $request | |||
| 53 | * @param \Mageplaza\LayeredNavigation\Helper\Data $moduleHelper | 54 | * @param LayerHelper $moduleHelper | |||
| 54 | */ | 55 | */ | |||
| 55 | public function __construct( | 56 | public function __construct( | |||
| 56 | UrlInterface $url, | 57 | UrlInterface $url, | |||
| 57 | Pager $htmlPagerBlock, | 58 | Pager $htmlPagerBlock, | |||
| 58 | RequestInterface $request, | 59 | RequestInterface $request, | |||
| 59 | LayerHelper $moduleHelper | 60 | LayerHelper $moduleHelper | |||
| 60 | ) | 61 | ) { | |||
| 61 | { | |||||
| 62 | $this->_url = $url; | 62 | $this->_url = $url; | |||
| 63 | $this->_htmlPagerBlock = $htmlPagerBlock; | 63 | $this->_htmlPagerBlock = $htmlPagerBlock; | |||
| 64 | $this->_request = $request; | 64 | $this->_request = $request; | |||
| 65 | $this->_moduleHelper = $moduleHelper; | 65 | $this->_moduleHelper = $moduleHelper; | |||
| 66 | } | 66 | } | |||
| 67 | 67 | |||||
| 68 | /** | 68 | /** | |||
| 69 | * @param \Magento\Catalog\Model\Layer\Filter\Item $item | 69 | * @param \Magento\Catalog\Model\Layer\Filter\Item $item | |||
| 70 | * @param $proceed | 70 | * @param $proceed | |||
| 71 | * | |||||
| 71 | * @return string | 72 | * @return string | |||
| 72 | * @throws \Magento\Framework\Exception\LocalizedException | 73 | * @throws | |||
| 73 | */ | 74 | */ | |||
| 74 | public function aroundGetUrl(\Magento\Catalog\Model\Layer\Filter\Item $item, $proceed) | 75 | public function aroundGetUrl(\Magento\Catalog\Model\Layer\Filter\Item $item, $proceed) | |||
| 75 | { | 76 | { | |||
| 76 | if (!$this->_moduleHelper->isEnabled()) { | 77 | if (!$this->_moduleHelper->isEnabled()) { | |||
| 77 | return $proceed(); | 78 | return $proceed(); | |||
| 78 | } | 79 | } | |||
| 79 | 80 | |||||
| 80 | $value = []; | 81 | $value = []; | |||
| 81 | $filter = $item->getFilter(); | 82 | $filter = $item->getFilter(); | |||
| 82 | $filterModel = $this->_moduleHelper->getFilterModel(); | 83 | $filterModel = $this->_moduleHelper->getFilterModel(); | |||
| 83 | if ($filterModel->getIsSliderTypes($filter) || $filter->getData('range_mode')) { | 84 | if ($filterModel->isSliderTypes($filter) || $filter->getData('range_mode')) { | |||
| 84 | $value = ["from-to"]; | 85 | $value = ["from-to"]; | |||
| 85 | } else if ($filterModel->isMultiple($filter)) { | 86 | } elseif ($filterModel->isMultiple($filter)) { | |||
| 86 | $requestVar = $filter->getRequestVar(); | 87 | $requestVar = $filter->getRequestVar(); | |||
| 87 | if ($requestValue = $this->_request->getParam($requestVar)) { | 88 | if ($requestValue = $this->_request->getParam($requestVar)) { | |||
| 88 | $value = explode(',', $requestValue); | 89 | $value = explode(',', $requestValue); | |||
| 89 | } | 90 | } | |||
| 90 | if (!in_array($item->getValue(), $value | 91 | if (!in_array($item->getValue(), $value, true)) { | |||
| 91 | $value[] = $item->getValue(); | 92 | $value[] = $item->getValue(); | |||
| 92 | } | 93 | } | |||
| 93 | } | 94 | } | |||
| 94 | 95 | |||||
| 95 | //Sort param on Url | 96 | //Sort param on Url | |||
| 96 | sort($value); | 97 | sort($value); | |||
| 97 | 98 | |||||
| 98 | if (sizeof($value)) { | 99 | if (!empty($value)) { | |||
| 99 | $query = [ | 100 | $query = [ | |||
| 100 | $filter->getRequestVar() => implode(',', $value), | 101 | $filter->getRequestVar() => implode(',', $value), | |||
| 101 | // exclude current page from urls | 102 | // exclude current page from urls | |||
| 102 | $this->_htmlPagerBlock->getPageVarName() => null, | 103 | $this->_htmlPagerBlock->getPageVarName() => null, | |||
| 103 | ]; | 104 | ]; | |||
| 104 | 105 | |||||
| 105 | return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]); | 106 | return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]); | |||
| 106 | } | 107 | } | |||
| 107 | 108 | |||||
| 108 | return $proceed(); | 109 | return $proceed(); | |||
| 109 | } | 110 | } | |||
| 110 | 111 | |||||
| 111 | /** | 112 | /** | |||
| 112 | * @param \Magento\Catalog\Model\Layer\Filter\Item $item | 113 | * @param \Magento\Catalog\Model\Layer\Filter\Item $item | |||
| 113 | * @param $proceed | 114 | * @param $proceed | |||
| 115 | * | |||||
| 114 | * @return string | 116 | * @return string | |||
| 115 | * @throws \Magento\Framework\Exception\LocalizedException | 117 | * @throws | |||
| 116 | */ | 118 | */ | |||
| 117 | public function aroundGetRemoveUrl(\Magento\Catalog\Model\Layer\Filter\Item $item, $proceed) | 119 | public function aroundGetRemoveUrl(\Magento\Catalog\Model\Layer\Filter\Item $item, $proceed) | |||
| 118 | { | 120 | { | |||
| 119 | if (!$this->_moduleHelper->isEnabled()) { | 121 | if (!$this->_moduleHelper->isEnabled()) { | |||
| 120 | return $proceed(); | 122 | return $proceed(); | |||
| 121 | } | 123 | } | |||
| 122 | 124 | |||||
| 123 | $value = []; | 125 | $value = []; | |||
| 124 | $filter = $item->getFilter(); | 126 | $filter = $item->getFilter(); | |||
| 125 | $filterModel = $this->_moduleHelper->getFilterModel(); | 127 | $filterModel = $this->_moduleHelper->getFilterModel(); | |||
| 126 | if ($filterModel->isMultiple($filter)) { | 128 | if ($filterModel->isMultiple($filter)) { | |||
| 127 | $value = $filterModel->getFilterValue($filter); | 129 | $value = $filterModel->getFilterValue($filter); | |||
| 128 | if (in_array( | 130 | if (in_array((string) $item->getValue(), $value, true)) { | |||
| 129 | $value = array_diff($value, [$item->getValue()]); | 131 | $value = array_diff($value, [$item->getValue()]); | |||
| 130 | } | 132 | } | |||
| 131 | } | 133 | } | |||
| 132 | 134 | |||||
| 133 | $params['_query'] = [$filter->getRequestVar() => count($value) ? implode(',', $value) : $filter->getResetValue()]; | 135 | $params['_query'] = [ | |||
| 136 | $ | |||||
| 137 | ]; | |||||
| 134 | $params['_current'] = true; | 138 | $params['_current'] = true; | |||
| 135 | $params['_use_rewrite'] = true; | 139 | $params['_use_rewrite'] = true; | |||
| 136 | $params['_escape'] = true; | 140 | $params['_escape'] = true; | |||
| 137 | 141 | |||||
| 138 | return $this->_url->getUrl('*/*/*', $params); | 142 | return $this->_url->getUrl('*/*/*', $params); | |||
| 139 | } | 143 | } | |||
| 140 | } | 144 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.